package com.cxs.slidertest.slice;

import com.cxs.slidertest.ResourceTable;
import com.cxs.slidertest.component.Test;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.*;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        DirectionalLayout layout = (DirectionalLayout)findComponentById(ResourceTable.Id_child_layout);
        Test test = new Test(this);
        // 重要， 将test组件添加到child_layout布局中
        layout.addComponent(test);

        findComponentById(ResourceTable.Id_ability_main_button).setClickedListener(c -> {
            test.changeText();
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

}
